package com.zry.traced.retrofit


import com.zry.traced.been.*
import com.zry.traced.greendao.entity.FlowRecordInfo
import com.zry.traced.update.UpdateAppInfo
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST
import rx.Observable

/**
 * 数据接口api
 */

interface ApiDynamic {
    /**
     * 登陆
     */
    @FormUrlEncoded
    @POST("login")
    fun loginApi(@Field("username") username: String, @Field("password") password: String, @Field("juris") juris: String)
            : Observable<HttpResponse<LoginInfoBean>>

    /**
     * 获取产品列表
     */
    @FormUrlEncoded
    @POST("GetProductList")
    fun GetProductList(@Field("enterpriseId") enterpriseId: String): Observable<MutableList<ProductInfo>>

    /**
     * 获取生产批次
     */
    @FormUrlEncoded
    @POST("GetBatchByProductId")
    fun GetBatchByProductId(@Field("productId") productId: String): Observable<MutableList<BatchInfo>>

    /**
     * 获取生产线
     */
    @FormUrlEncoded
    @POST("GetProductionLine")
    fun GetProductionLine(@Field("enterpriseId") enterpriseId: String): Observable<MutableList<ProductLine>>

    /**
     * 获取装箱单位列表
     */
//    @FormUrlEncoded
    @POST("GetPackList")
    fun GetPackList(): Observable<MutableList<PacKBean>>

    /**
     * 根据短追溯码获取长追溯码
     */
    @FormUrlEncoded
    @POST("GetCodeID")
    fun GetCodeID(@Field("newCode") newCode: String, @Field("pid") pid: String, @Field("stype") stype: String,
                  @Field("parentCode") parentCode: String): Observable<ResultCode>

    /**
     * 根据短流通码获取长流通吗
     */
    @FormUrlEncoded
    @POST("GetFlowCode")
    fun GetFlowCode(@Field("newCode") newCode: String, @Field("pid") pid: String, @Field("stype") stype: String, @Field("orderType") orderType: String,
                    @Field("parentCode") parentCode: String): Observable<ResultFlowCode>

    /**
     * 批量打包
     */
    @FormUrlEncoded
    @POST("AddLiangFlow")
    fun AddLiangFlow(@Field("level") level: String, @Field("ProductID") ProductID: String, @Field("UnitID") UnitID: String,
                     @Field("SonCodeNum") SonCodeNum: String, @Field("CodeS") CodeS: String, @Field("UserID") UserID: String,
                     @Field("EnterpriseID") EnterpriseID: String): Observable<ResultCodeData<MutableList<PackResultCode>>>

    /**
     * 号段打包
     */
    @FormUrlEncoded
    @POST("AddDuanFlow")
    fun AddDuanFlow(@Field("level") level: String, @Field("ProductID") ProductID: String,
                    @Field("UnitID") UnitID: String, @Field("SonCodeNum") SonCodeNum: String,
                    @Field("MaxCode") MaxCode: String, @Field("MinCode") MinCode: String,
                    @Field("UserID") UserID: String, @Field("EnterpriseID") EnterpriseID: String)
            : Observable<ResultCodeData<MutableList<PackResultCode>>>


    /**
     * 获取装箱记录
     */
    @FormUrlEncoded
    @POST("GetFlowCodeList")
    fun GetFlowCodeList(@Field("EnterpriseID") EnterpriseID: String, @Field("CreateUserID") CreateUserID: String,
                        @Field("pageIndex") pageIndex: Int, @Field("pageSize") pageSize: Int): Observable<MutableList<FlowCode>>

    /**
     * 获取批量打包记录详情
     */
    @FormUrlEncoded
    @POST("GetFlowCodeDetailList")
    fun GetFlowCodeDetailList(@Field("FlowCodeID") FlowCodeID: String): Observable<HttpResponse<FlowCodeDetail>>

    /**
     * 获取入库订单列表
     */
    @FormUrlEncoded
    @POST("GetStoreOrderListPDA")
    fun GetStoreOrderList(@Field("EnterpriseID") EnterpriseID: String, @Field("pageIndex") pageIndex: Int, @Field("pageSize") pageSize: Int): Observable<MutableList<StoreOrderBean>>

    /**
     * 批量入库
     */
    @FormUrlEncoded
    @POST("AddLiangStore")
    fun AddLiangStore(@Field("OrderID") OrderID: String, @Field("CodeS") CodeS: String,
                      @Field("UserID") UserID: String): Observable<ResultCodeData<MutableList<PackResultCode>>>

    /**
     * 号段入库
     */
    @FormUrlEncoded
    @POST("AddDuanStore")
    fun AddDuanStore(@Field("OrderID") OrderID: String, @Field("MaxCode") MaxCode: String, @Field("MinCode") MinCode: String,
                     @Field("UserID") UserID: String): Observable<ResultCodeData<MutableList<PackResultCode>>>

    /**
     * 入库记录
     */
    @FormUrlEncoded
    @POST("GetStoreDetailList")
    fun GetStoreDetailList(@Field("CreateUserID") CreateUserID: String, @Field("pageIndex") pageIndex: Int, @Field("pageSize") pageSize: Int): Observable<MutableList<StoreDetail>>

    /**
     * 入库记录详情
     */
    @FormUrlEncoded
    @POST("GetStoreDetailInfo")
    fun GetStoreDetailInfo(@Field("DetailID") DetailID: String): Observable<StoreDetail>

    /**
     * 出库订单列表
     */
    @FormUrlEncoded
    @POST("GetOutStockListPDA")
    fun GetOutStockList(@Field("EnterpriseID") EnterpriseID: String, @Field("pageIndex") pageIndex: Int, @Field("pageSize") pageSize: Int): Observable<MutableList<OutStock>>

    /**
     * 批量出库
     */
    @FormUrlEncoded
    @POST("AddLiangOutStockDetail")
    fun AddLiangOutStockDetail(@Field("OutStockID") OutStockID: String, @Field("ProductID") ProductID: String,
                               @Field("OutLevel") OutLevel: String, @Field("CodeS") CodeS: String,
                               @Field("CreateUserID") CreateUserID: String, @Field("EnterpriseID") EnterpriseID: String)
            : Observable<ResultCodeData<MutableList<PackResultCode>>>

    /**
     * 号段出库
     */
    @FormUrlEncoded
    @POST("AddDuanOutStockDetail")
    fun AddDuanOutStockDetail(@Field("OutStockID") OutStockID: String, @Field("ProductID") ProductID: String, @Field("OutLevel") OutLevel: String,
                              @Field("MinCode") MinCode: String, @Field("MaxCode") MaxCode: String, @Field("CreateUserID") CreateUserID: String,
                              @Field("EnterpriseID") EnterpriseID: String): Observable<ResultCodeData<MutableList<PackResultCode>>>

    /**
     * 出库记录
     */
    @FormUrlEncoded
    @POST("GetOutDetailList")
    fun GetOutDetailList(@Field("CreateUserID") CreateUserID: String, @Field("pageIndex") pageIndex: Int, @Field("pageSize") pageSize: Int)
            : Observable<MutableList<OutDetailBean>>

    /**
     * 出库记录详情
     */
    @FormUrlEncoded
    @POST("GetOutDetailInfo")
    fun GetOutDetailInfo(@Field("DetailID") DetailID: String): Observable<OutDetailBean>

    /**
     * 补码装箱、分箱拆码获取短码的信息
     */
    @FormUrlEncoded
    @POST("GetFlowCodeInfo")
    fun GetFlowCodeInfo(@Field("CodeID") CodeID: String, @Field("stype") stype: Int): Observable<FlowCodeInfo>

    /**
     *补码入箱
     */
    @FormUrlEncoded
    @POST("ComplementFlow")
    fun ComplementFlow(@Field("CodeID") CodeID: String, @Field("SonCode") SonCode: String,
                       @Field("EnterpriseID") EnterpriseID: String, @Field("CreateUserID") CreateUserID: String): Observable<FlowCodeInfo>

    /**
     * 拆码出箱
     */
    @FormUrlEncoded
    @POST("DismantlingFlow")
    fun DismantlingFlow(@Field("CodeID") CodeID: String, @Field("SonCode") SonCode: String, @Field("EnterpriseID") EnterpriseID: String,
                        @Field("CreateUserID") CreateUserID: String): Observable<FlowCodeInfo>

    /**
     * 补码入箱、拆码出箱记录
     */
    @FormUrlEncoded
    @POST("GetFlowRecordList")
    fun GetFlowRecordList(@Field("CreateUserID") CreateUserID: String, @Field("EnterpriseID") EnterpriseID: String,
                          @Field("StateID") StateID: String, @Field("pageIndex") pageIndex: Int, @Field("pageSize") pageSize: Int)
            : Observable<MutableList<FlowRecord>>

    /**
     * 补码、拆码详情
     */
    @FormUrlEncoded
    @POST("GetFlowRecordInfo")
    fun GetFlowRecordInfo(@Field("RecordID") RecordID: String): Observable<FlowRecordInfo>

    /**
     * 检验当前是否有新版本
     */
    @FormUrlEncoded
    @POST("checkApp")
    fun checkApp(@Field("vNumber") vNumber: String, @Field("VersionType") VersionType: String): Observable<UpdateAppInfo>
}